package com.jdk.demo.nio.bytebuffer;

import java.nio.ByteBuffer;

public class GetAndPut {

	public static void main(String[] args) {
		ByteBuffer buffer1 = ByteBuffer.allocate(10);
		System.out.println("A1 byteBuffer1 capacity=" + buffer1.capacity() + ", position=" + buffer1.position() + " limit=" + buffer1.limit());

		buffer1.put((byte)125);
		System.out.println("A2 byteBuffer1 capacity=" + buffer1.capacity() + ", position=" + buffer1.position() + " limit=" + buffer1.limit());
		buffer1.put((byte)126);
		System.out.println("A3 byteBuffer1 capacity=" + buffer1.capacity() + ", position=" + buffer1.position() + " limit=" + buffer1.limit());
		buffer1.put((byte)127);
		System.out.println("B byteBuffer1 capacity=" + buffer1.capacity() + ", position=" + buffer1.position() + " limit=" + buffer1.limit());

		buffer1.rewind();
		System.out.println("C byteBuffer1 capacity=" + buffer1.capacity() + ", position=" + buffer1.position() + " limit=" + buffer1.limit());
		System.out.println(buffer1.get());
		System.out.println("D byteBuffer1 capacity=" + buffer1.capacity() + ", position=" + buffer1.position() + " limit=" + buffer1.limit());
		System.out.println(buffer1.get());
		System.out.println("E byteBuffer1 capacity=" + buffer1.capacity() + ", position=" + buffer1.position() + " limit=" + buffer1.limit());
		System.out.println(buffer1.get());
		System.out.println("F byteBuffer1 capacity=" + buffer1.capacity() + ", position=" + buffer1.position() + " limit=" + buffer1.limit());
		System.out.println(buffer1.get());
	}

}
